//
//  MineMessageContentViewController.m
//  copyrightTrading
//
//  Created by 郭子一 on 2020/10/6.
//  Copyright © 2020 郭子一. All rights reserved.
//

#import "MineMessageContentViewController.h"
#import <WebKit/WebKit.h>
@interface MineMessageContentViewController ()

@end

@implementation MineMessageContentViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)setupUI
{
    UIView *headerView = [UIView new];
    headerView.backgroundColor = RGB_VALUE(0xDC0000);
    [self.view addSubview:headerView];
    [headerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.offset(0);
        make.height.mas_equalTo(Height_NavBar);
    }];
    
    UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [backBtn setImage:[UIImage imageNamed:@"whiteBack"] forState:UIControlStateNormal];
    [backBtn addTarget:self action:@selector(backBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [backBtn setHitEdgeInsets:UIEdgeInsetsMake(-15, -15, -15, -15)];
    [headerView addSubview:backBtn];
    [backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.offset(-14);
        make.left.offset(18);
        make.width.height.mas_equalTo(16);
    }];
    
    UILabel *titleLabel = [UILabel new];
    titleLabel.text = @"消息详情";
    titleLabel.font = JSS_MEDIUM_FONT(17);
    titleLabel.textColor = RGB_VALUE(0xFFFFFF);
    titleLabel.textAlignment = NSTextAlignmentCenter;
    [headerView addSubview:titleLabel];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.offset(-9);
        make.centerX.offset(0);
        make.width.mas_equalTo(135);
        make.height.mas_equalTo(24);
    }];
    
    WKWebView *web = [[WKWebView alloc] init];//WithFrame:CGRectMake(0, backBtn.bottom, KDeviceWidth, KDeviceHeight - Height_NavBar)
    web.allowsBackForwardNavigationGestures = YES;
//    web.navigationDelegate = self;
//    web.UIDelegate = self;
    [self.view addSubview:web];
    [web mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(headerView.mas_bottom).offset(0);
        make.left.right.bottom.offset(0);
    }];
    
    NSURL *url = [NSURL URLWithString:@"https://mp.weixin.qq.com/s/JcBw8RvFxiCOD74zJSPBzQ"];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
    [web loadRequest:request];
    
    [[APIManager sharedNetManager] requestWithMethod:HttpRequestTypePost URLString:@"message" parameters:@{@"id":@(self.messageId)} done:^(NSURLSessionDataTask * _Nonnull task, id  _Nonnull responseObject) {
        
    } fail:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) {
        
    }];
}

- (void)backBtnClick
{
    [self.navigationController popViewControllerAnimated:YES];
}

@end
